home *** CD-ROM | disk | FTP | other *** search
- WGT Menus
- Copyright 1993 Chris Egerter
-
- WGT Menus provides a quick and easy method of selecting options
- available to the end user. If you have a mouse, you can simply
- move to the item you want, and click the mouse button. If do
- not have a mouse, use the arrow keys to move around in the
- drop down menus.
-
-
- Creating a drop down menu:
-
- First you need to define what the names of the drop down menus will be.
- This is done be entering them into an array at the beginning of your
- program:
-
- char *menubar[10]={" QUIT "," FILES "," Menu 1 "," Menu 2 ",NULL,NULL,NULL,NULL,NULL,NULL};
-
- These names will appear on the 'menu bar' at the top of the screen.
- Notice how some are 'NULL'. These will not show anything on the menu bar.
- I suggest you put spaces on either side of the names, to keep the choices
- apart. When a user moves the mouse over these names (or presses F10 when
- there is no mouse installed), a sub-menu will appear.
-
- To define the sub-menus, you must enter each choice as follows:
-
- dropdown[0].choice[0]=" Help ";
- dropdown[0].choice[1]=" Quit ";
- dropdown[1].choice[0]=" Load ";
- dropdown[1].choice[1]=" Save ";
- ^ ^
- Menu # --| |--Choice #
-
-
- This would make sub-menus under the first and second drop-down choices.
- It would look like this:
-
- Quit Files Menu 1 Menu 2
- | Help || Load |
- | Quit || Save |
- |------||------|
-
- The format for sub-menus is:
- dropdown[n].choice[n]="Your choice"
-
- with n ranging from 0 to 9.
-
- This means you can have up to 10 drop down menus, with up to 10
- choices in each, for a total of 100 choices available to the user
- at a click of the mouse button!
-
-
- Available functions:
-
- void initdropdowns();
-
- Initializes drop-down menus and sub-menus.
- You must call this after you have defined the drop down menus and
- sub-menus.
- If you change the text in the menus, (such as toggling choices) you
- may need to call this again, to get the correct sizes for the sub-menus.
-
- --------------------------------------------------------------------------
- void showmenubar();
-
- Shows the drop-down menu bar at the top of the screen.
-
- --------------------------------------------------------------------------
- int checkmenu();
-
- Loops until the user selects a choice from the menu bar or clicks
- the mouse button outside of the menu bar.
- If a selection is made, it returns the number of the menu choice.
-
- If you selected this choice, it would return the number 11.
- dropdown[1].choice[1]=" Save ";
-
- result= menu*10 + choice
- = 1*10 + 1
- = 11
-
- If the mouse is clicked outside the menu, it returns -1.
-
- --------------------------------------------------------------------------
- void removemenubar();
-
- Removes the menu bar from the screen.
-
- --------------------------------------------------------------------------
-
- Available variables:
-
- Each drop down menu can have different colours.
- To set them, set the following variables:
-
- dropdown[0].color=?
- dropdown[0].bordercolor=?
- dropdown[0].textcolor=?
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- The menu bar can have different colours as well by setting:
-
- menubarcolor=254;
- menubartextcolor=1;
- bordercolor=255;
- highlightcolor=144;
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- To see if the mouse is installed, check the variable:
-
- int mouseinstalled; =1 if installed, 0 if not installed
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- At default, the hotkey which brings the drop down menus from the keyboard
- is F10. You can change this key by changing the value in
-
- char menuhotkey;
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- With WGT Menus, you can create menus with any font you like.
- To change the font, load a new one in with wloadfont and set
-
- wgtfont menufont;
-
- eg. myfont=wloadfont("the_font.fnt");
- menufont=myfont;
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Please see the example files for a full demonstration.
-